package com.app.qtjk.lsh.ctrl;
import java.util.ArrayList;
import java.util.HashMap;

import com.app.common.utils.FilterUtil;
import com.css.sword.kernel.utils.SwordLogUtils;
import com.css.sword.kernel.utils.SwordServiceUtils;
import com.css.sword.platform.web.controller.BaseDomainCtrl;
import com.css.sword.platform.web.controller.annotations.CTRL;
import com.css.sword.platform.web.event.IReqData;
import com.css.sword.platform.web.event.IResData;
import com.css.sword.platform.web.event.SwordRes;


@CTRL("UserprizeOrderCtrl")
public class UserprizeOrderCtrl extends BaseDomainCtrl {

	private static SwordLogUtils log = SwordLogUtils.getLogger(UserprizeOrderCtrl.class);

	/**
	 * 确认订单保存
	 * @param req
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public IResData saveOrder(IReqData req) throws Exception{

		log.debug("开始进入 UserprizeOrderCtrl_saveOrder 方法。");

		IResData res = new SwordRes();
		HashMap commonMap = new HashMap();
		ArrayList commonList = new ArrayList();		
		HashMap hashMap = new HashMap();
		//检查请求口令是否正确
		boolean checkToken = FilterUtil.checkToken(req);
		try {
			if (checkToken == true) {
				hashMap.put("returnStatus", "true");
				res=(IResData) SwordServiceUtils.callService("UserprizeOrderService_save", req);
				if ((Boolean)res.get("status") == true) {
					hashMap.put("status", "true");
				} else {
					hashMap.put("status", "false");
				}
			} else {
				hashMap.put("returnStatus", "false");
				hashMap.put("msg", "请求口令错误！");
			}
		} catch (Exception e) {
			log.debug("---------------系统异常！---------------");
			e.printStackTrace();
			hashMap.put("returnStatus", "false");
			hashMap.put("msg", "出现异常！");
		} finally {
			commonMap.put("commonData", hashMap);
			commonList.add(commonMap);
			res.addListWithDataName("returnData", commonList);
		}
		
		return res;
	}

	 		
	/**
	 * 得到订单详情，尤其订单状态
	 */
	public IResData getOrderDetail(IReqData req) throws Exception{

		log.debug("开始进入 UserprizeOrderCtrl_getOrderDetail 方法。");

		IResData res = new SwordRes();
		System.out.println("icomein");
		return res;

	}

	 		
	/**
	 * 用户确认收货
	 * @param req
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public IResData confirmSh(IReqData req) throws Exception{

		log.debug("开始进入 UserprizeOrderCtrl_confirmSh 方法。");

		IResData res = new SwordRes();
		HashMap commonMap = new HashMap();
		ArrayList commonList = new ArrayList();		
		HashMap hashMap = new HashMap();
		//检查请求口令是否正确
		boolean checkToken = FilterUtil.checkToken(req);
		try {
			if (checkToken == true) {
				hashMap.put("returnStatus", "true");
				res=(IResData) SwordServiceUtils.callService("UserprizeOrderService_confirmSh", req);
				if ((Boolean)res.get("status") == true) {
					hashMap.put("status", "true");
				} else {
					hashMap.put("status", "false");
				}
			} else {
				hashMap.put("returnStatus", "false");
				hashMap.put("msg", "请求口令错误！");
			}
		} catch (Exception e) {
			log.debug("---------------系统异常！---------------");
			e.printStackTrace();
			hashMap.put("returnStatus", "false");
			hashMap.put("msg", "出现异常！");
		} finally {
			commonMap.put("commonData", hashMap);
			commonList.add(commonMap);
			res.addListWithDataName("returnData", commonList);
		}
		
		return res;
	}
	
	 		


}